<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/js/jquery.min.js"></script>
    <style>
        #table1{
            border:1px solid #2aabd2;
            width: 50%;
            background-color: lightcyan;
        }
        #table3{
            border:1px solid #2aabd2;
            width: 50%;
            background-color: lightcyan;
        }
        #table2{
            width: 100%;
        }
        #table2 tr:nth-child(odd){
            background-color: #eee;
        }
        #table2 tr:hover{
            background-color: #ccc;
        }
        #table2 tr td:first-child{
            color: #f40;
        }

        #table2 tr td{
            text-align: right;
            padding-right: 20px;
        }
    </style>
</head>
<body>
<!--<button th:text="操作" th:value="${everyCus.custId}" onclick="ajaxbt(this.value)"></button>-->
<form action="xitong_selectCustomer.do">
    <table id="table1" border="1">
        <tr>
            <td colspan="5">客户ID</td>
            <td><input type="text" id="custID" name="custID" th:value="${session.custID}"></td>
        </tr>
        <tr>
            <td colspan="5">客户名称</td>
            <td><input type="text" id="custName" name="custName" th:value="${session.custName}"></td>
        </tr>
        <tr>
            <td colspan="5">IC卡号</td>
            <td><input type="text" id="custIC" name="custIC" th:value="${session.custIC}"></td>
        </tr>
        <tr>
            <td colspan="5"><input type="submit" value="查询"></td>
            <td></td>
        </tr>
    </table>
    每页显示条数<select name="pageRows" id="pageRows" onchange="lastpage1(this.value)">
        <option th:each="i:${session.list}" th:text="${i}" th:value="${i}" th:selected="${session.pageRows == i}"></option>
    </select>
    第<label th:text="${session.pageInfo.getPageNum()}"></label>页
    <input type="hidden" th:value="${session.pageInfo.getPageNum()}" id="pageNum">

</form>
    <label th:if="${session.pageInfo.size==0}" style="color: #ff4400">没有查到任何数据!请核对查询信息</label>
    <table id="table2" th:if="${session.pageInfo.size!=0}">
        <tr><td>操作</td><td>客户ID</td><td>客户名</td><td>客户IC</td><td>IC硬件</td><td>固话</td><td>手机号</td><td>性别</td><td>编辑时间</td></tr>
        <tr th:each="everyCus:${session.pageInfo.getList()}"><td><input type="radio" name="ever" th:value="${everyCus.custId}" class="input1"></td><td th:text="${everyCus.custId}"></td><td th:text="${everyCus.custName}"></td><td th:text="${everyCus.custIc}"></td><td th:text="${everyCus.custIcChip}"></td><td th:text="${everyCus.custTel}"></td><td th:text="${everyCus.custMobile}"></td><td th:text="${everyCus.custSex}"></td><td th:text="${everyCus.custEditTime}"></td></tr>
        <tr><button th:value="${session.pageInfo.getPageNum()>1?session.pageInfo.getPageNum()-1:session.pageInfo.getPageNum()}" onclick="lastpage(this.value)">上一页</button>
            <button th:value="${session.pageInfo.getPageNum()<session.pageInfo.pages?session.pageInfo.getPageNum()+1:session.pageInfo.getPageNum()}" onclick="lastpage(this.value)">下一页</button></tr>
    </table>
    <form action="xitong_update.do">
    <table id="table3" >
<!--        <tr><td>货主编号</td><td><input type='hidden' id='custID1' name='custId' th:value="${session.wmsTCustomer.custId}"><input type='text' disabled='disabled' th:value="${session.wmsTCustomer.custId}"></td></tr>-->
<!--        <tr><td>货主名称</td><td><input type='text'  id='custName1' name='custName' th:value="${session.wmsTCustomer.custName}"></td></tr>-->
<!--        <tr><td>IC卡编号</td><td><input type='text'  id='custIC1' name='custIc' th:value="${session.wmsTCustomer.custIc}"></td></tr>-->
<!--        <tr><td>固话号码</td><td><input type='text'  id='custTel' name='custTel' th:value="${session.wmsTCustomer.custTel}"></td></tr>-->
<!--        <tr><td>手机号码</td><td><input type='text'  id='custMobile' name='custMobile' th:value="${session.wmsTCustomer.custMobile}"></td></tr>-->
<!--        <tr><td>性别</td><td><input type='radio' name='custSex' value='男' id='men' th:checked="${session.wmsTCustomer.custSex eq '男'}"><label for='men'>男</label><input type='radio' name='custSex' value='女' id='femen' th:checked="${session.wmsTCustomer.custSex eq '女'}"><label for='femen'>女</label></td></tr>-->
<!--        <tr><td rowspan='3'>备注</td><td rowspan='3'><textarea cols='30' rows='3' name="custNote" id="custNote" th:value="${session.wmsTCustomer.custNote}"></textarea></td></tr>-->
<!--        <tr><td>编辑时间</td><td><input name='custEditTime' id='time'></td></tr>-->
<!--        <tr><td>状态</td><td><input type='radio' value='delete' name='edit' id='delete'><label for='delete'>删除</label><input type='radio' value='edit' id='edit' name='edit' checked='checked'><label for='edit'>操作</label></td></tr>-->
<!--        <tr><td></td><td><input type="submit" value="提交"><input type="reset" value="重置"></td></tr>-->
    </table>
    </form>
</body>
<script type="text/javascript">
    $(function () {
        $(".input1").click(function () {

            ajaxbt(this);
        })

    })
    function lastpage(page) {
        var custName = $("#custName").val();
        var custIC = $("#custIC").val();
        var custID = $("#custID").val();
        var pagerows = $("#pageRows").val();
        window.location = "xitong_selectCustomer.do?pageNum="+page+"&pageRows="+pagerows+"&custName="+custName+"&custIC="+custIC+"&custID="+custID;
    }
    function lastpage1(row) {
        var custName = $("#custName").val();
        var custIC = $("#custIC").val();
        var custID = $("#custID").val();
        var pageNum = $("#pageNum").val();
        window.location = "xitong_selectCustomer.do?pageNum="+pageNum+"&pageRows="+row+"&custName="+custName+"&custIC="+custIC+"&custID="+custID;
    }
    function datetime() {
        var now = new Date();
        document.getElementById("time").value = now.getFullYear() + "-"
            + (now.getMonth() + 1) + "-" + now.getDate()+" ";
        document.getElementById("time").value += " " + now.getHours() + ":"
            + now.getMinutes() + ":" + now.getSeconds();
    }
    window.setInterval("datetime()");
    function ajaxbt(custID) {
        // $("#table3").html("");
        var custV = custID.value;
        $("#table3").html("");
        $.ajax({

            type:"get",
            url:"xitong_getOnecust.do?custID="+custV,
            dataType:"json",
            success:function (data) {
                $("#table3").append("<tr><td>货主编号</td><td><input type='hidden' id='custID1' name='custId' value="+data.custId+"><input type='text' disabled='disabled' value="+data.custId+"></td></tr>\n" +
                    "        <tr><td>货主名称</td><td><input type='text'  id='custName1' name='custName' value="+data.custName+"></td></tr>\n" +
                    "        <tr><td>IC卡编号</td><td><input type='text'  id='custIC1' name='custIc' value="+data.custIc+"></td></tr>\n" +
                    "        <tr><td>固话号码</td><td><input type='text'  id='custTel' name='custTel' value="+data.custTel+"></td></tr>\n" +
                    "        <tr><td>手机号码</td><td><input type='text'  id='custMobile' name='custMobile' value="+data.custMobile+"></td></tr>\n" +
                    "        <tr><td>性别</td><td><input type='radio' name='custSex' value='男' id='men' class='men'><label for='men'>男</label><input type='radio' name='custSex' value='女' id='femen' class='women'><label for='femen'>女</label></td></tr>\n" +
                    "        <tr><td rowspan='3'>备注</td><td rowspan='3'><textarea cols='30' rows='3' name=\"custNote\" id=\"custNote\" value="+data.custNote+"></textarea></td></tr>\n" +
                    "        <tr><td>编辑时间</td><td><input name='custEditTime' id='time'></td></tr>\n" +
                    "        <tr><td>状态</td><td><input type='radio' value='delete' name='edit' id='delete'><label for='delete'>删除</label><input type='radio' value='edit' id='edit' name='edit' checked='checked'><label for='edit'>操作</label></td></tr>\n" +
                    "        <tr><td></td><td><input type=\"submit\" value=\"提交\"><input type=\"reset\" value=\"重置\"></td></tr>");

                    if(data.custSex=='男'){
                        $(".men").attr("checked","true");
                    }
                    if(data.custSex=='女'){
                        $(".women").attr("checked","true");
                    }

                // window.location.reload();
            }
        })
    }

</script>
</html>